package pzl.com;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by Administrator on 2016-03-22.
 */
public class TestView extends View {
    Paint paint;

    public TestView(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        paint.setColor(Color.WHITE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Log.i("TestView", "onDraw");

        paint.setStrokeWidth(10);
        canvas.drawLine(20, 20, getWidth(), 20, paint);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int ACTION = event.getAction();
        if (ACTION == MotionEvent.ACTION_DOWN) {
            Log.i("TestView", "ACTION_DOWN");
            paint.setColor(Color.RED);
            invalidate(getWidth() / 2 - 30, 0, getWidth() / 2 + 30, 500);
            // invalidate();
        }
        return true;
    }
}
